package deepbitview

/**
 * a service to interact with your locally running bitcoin daemon
 */
class WalletService {

    static transactional = true

    def getBalance() {
        return executeQuery("getbalance")
    }

    /**
     * logs in and executes a query
     * @param parameter
     * @param path
     * @return
     */
    private def executeQuery(path, Map parameter = [:]) {

        if (WalletHandler.isConfigured()) {
            return JSONQueryUtil.executeQueryWithAuthentification("http://127.0.0.1:8332/", parameter, WalletHandler.getUserName(), WalletHandler.getPassword(), 'getbalance')

        }
        else {
            return false
        }
    }
}
